package com.demo.dao;

import com.demo.pojo.Item;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName ItemDao
 * @Description TODO
 * @Author Windy
 * @Date 2022/8/25 14:32
 * @Version 1.0
 **/
public interface ItemDao {

    //通过suid获取数据
    @Select("select * from item where suid=#{suid} and status=1")
    List<Item> findItemsBySuid(String suid);

    //插入数据
    @Insert("<script> insert into item(\n" +
            "            <trim suffixOverrides=\",\">\n" +
            "                <if test=\"iid!=null and iid!=''\">\n" +
            "                    iid,\n" +
            "                </if>         \n" +
            "                <if test=\"iname!=null and iname!=''\">\n" +
            "                    iname,\n" +
            "                </if>\n" +
            "                <if test=\"starttime!=null and starttime!=''\">\n" +
            "                    starttime,\n" +
            "                </if>\n" +
            "                <if test=\"endtime!=null and endtime!=''\">\n" +
            "                    endtime,\n" +
            "                </if>\n" +
            "                <if test=\"suid!=null and suid!=''\">\n" +
            "                    suid,\n" +
            "                </if>\n" +
            "                <if test=\"updatetime!=null and updatetime!=''\">\n" +
            "                    updatetime,\n" +
            "                </if>\n" +
            "            </trim>\n" +
            "        )\n" +
            "        values (\n" +
            "        <trim suffixOverrides=\",\">\n" +
            "            <if test=\"iid!=null and iid!=''\">\n" +
            "                #{iid},\n" +
            "            </if>\n" +
            "            <if test=\"iname!=null and iname!=''\">\n" +
            "                #{iname},\n" +
            "            </if>\n" +
            "            <if test=\"starttime!=null and starttime!=''\">\n" +
            "                #{starttime},\n" +
            "            </if>\n" +
            "            <if test=\"endtime!=null and endtime!=''\">\n" +
            "               #{endtime} ,\n" +
            "            </if>\n" +
            "            <if test=\"suid!=null and suid!=''\">\n" +
            "               #{suid} ,\n" +
            "            </if>\n" +
            "            <if test=\"updatetime!=null and updatetime!=''\">\n" +
            "               #{updatetime} ,\n" +
            "            </if>\n" +
            "        </trim>\n" +
            "        )"+
            "</script>")
    int insertItem(Item item);
}
